package com.hex.ds.hdtp.core.inf.data.contrast.repository.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hex.ds.hdtp.core.inf.common.page.Page;
import com.hex.ds.hdtp.core.inf.common.page.converter.IPageAndMyBatisPlusPageConverter;
import com.hex.ds.hdtp.core.inf.data.contrast.mapper.ICrossDbContrastListMapper;
import com.hex.ds.hdtp.core.inf.data.contrast.po.CrossDbContrastListPo;
import com.hex.ds.hdtp.core.inf.data.contrast.repository.ICrossDbContrastListRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Package: com.hex.ds.hdtp.core.inf.data.contrast.repository.impl
 * @ClassName CrossDbContrastListRepository
 * @Description: 跨库比对清单-数据接口实现
 * @Author: wz.li
 * @Date 2023/7/24 19:31
 * @Version v2.0.2
 **/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CrossDbContrastListRepository implements ICrossDbContrastListRepository {

    private final ICrossDbContrastListMapper crossDbContrastListMapper;

    private final IPageAndMyBatisPlusPageConverter pageConverter;

    /*
     * @Method: queryListByPage <br>
     * @Param: [crossDbContrastListPo, toPage] <br>
     * @Return: com.hex.ds.hdtp.core.inf.common.page.Page<com.hex.ds.hdtp.core.inf.data.contrast.po.CrossDbContrastListPo> <br>
     * @Description：分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/24 19:32 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Page<CrossDbContrastListPo> queryListByPage(CrossDbContrastListPo crossDbContrastListPo, Page toPage) {
        final IPage tmpPageResult = crossDbContrastListMapper.queryListByPage(
                pageConverter.toMyBatisPlusPage(toPage)
                , crossDbContrastListPo
        );
        final List list = tmpPageResult.getRecords();
        final Page pageResult = pageConverter.toPage(tmpPageResult);
        return pageResult.setData(list);
    }

    /*
     * @Method: queryList <br>
     * @Param: [crossDbContrastListPo] <br>
     * @Return: java.util.List<com.hex.ds.hdtp.core.inf.data.contrast.po.CrossDbContrastListPo> <br>
     * @Description：不分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/24 19:33 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public List<CrossDbContrastListPo> queryList(CrossDbContrastListPo crossDbContrastListPo) {
        return crossDbContrastListMapper.queryList(crossDbContrastListPo);
    }

    /**
     * @Method removeByTaskPkId
     * @Param
     * @param taskPkId
     * @Return void
     * @Description 根据任务主键删除
     * @Author Wang zhihao
     * @Date 2023/8/7 17:13
     * @Version V1.0
     */
    @Override
    public void removeByTaskPkId(String taskPkId) {
        crossDbContrastListMapper.deleteByTaskPkId(taskPkId);
    }

    /*
     * @Method: queryById <br>
     * @Param: [pkId] <br>
     * @Return: com.hex.ds.hdtp.core.inf.data.contrast.po.CrossDbContrastListPo <br>
     * @Description：根据主键查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/24 19:33 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public CrossDbContrastListPo queryById(String pkId) {
        return crossDbContrastListMapper.selectById(pkId);
    }

    /*
     * @Method: add <br>
     * @Param: [crossDbContrastListPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：新增<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/24 19:34 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer add(CrossDbContrastListPo crossDbContrastListPo) {
        return crossDbContrastListMapper.insert(crossDbContrastListPo);
    }

    /**
     * @Method addWithBackId
     * @Param
     * @param crossDbContrastListPo
     * @Return java.lang.String
     * @Description 新增并返回主键
     * @Author Wang zhihao
     * @Date 2023/8/16 17:45
     * @Version V1.0
     */
    @Override
    public String addWithBackId(CrossDbContrastListPo crossDbContrastListPo) {
        crossDbContrastListMapper.insert(crossDbContrastListPo);
        return crossDbContrastListPo.getPkId();
    }

    /**
     * @Method modifyStatus
     * @Param pkId
     * @Param status
     * @Return java.lang.Integer
     * @Description 更新状态
     * @Author gj.xu
     * @Date 2024/1/5 22:08
     * @Version V2.0
     */
    @Override
    public Integer modifyStatus(String pkId, String status) {
        return crossDbContrastListMapper.modifyStatus(pkId, status);
    }

    /*
     * @Method: modifyById <br>
     * @Param: [crossDbContrastListPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键更新<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/24 19:34 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer modifyById(CrossDbContrastListPo crossDbContrastListPo) {
        return crossDbContrastListMapper.updateById(crossDbContrastListPo);
    }

    /*
     * @Method: removeById <br>
     * @Param: [pkId] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键删除<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/24 19:34 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer removeById(String pkId) {
        return crossDbContrastListMapper.deleteById(pkId);
    }
}
